/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.BpmnPackage;
import bpmn.Complex;
import bpmn.Expression;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Complex</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.ComplexImpl#getIncomingCondition <em>Incoming Condition</em>}</li>
 *   <li>{@link bpmn.impl.ComplexImpl#getOutgoingCondition <em>Outgoing Condition</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ComplexImpl extends GatewayImpl implements Complex {
	/**
	 * The cached value of the '{@link #getIncomingCondition() <em>Incoming Condition</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIncomingCondition()
	 * @generated
	 * @ordered
	 */
	protected Expression incomingCondition;

	/**
	 * The cached value of the '{@link #getOutgoingCondition() <em>Outgoing Condition</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutgoingCondition()
	 * @generated
	 * @ordered
	 */
	protected Expression outgoingCondition;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComplexImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.COMPLEX;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression getIncomingCondition() {
		if (incomingCondition != null && incomingCondition.eIsProxy()) {
			InternalEObject oldIncomingCondition = (InternalEObject)incomingCondition;
			incomingCondition = (Expression)eResolveProxy(oldIncomingCondition);
			if (incomingCondition != oldIncomingCondition) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.COMPLEX__INCOMING_CONDITION, oldIncomingCondition, incomingCondition));
			}
		}
		return incomingCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression basicGetIncomingCondition() {
		return incomingCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIncomingCondition(Expression newIncomingCondition) {
		Expression oldIncomingCondition = incomingCondition;
		incomingCondition = newIncomingCondition;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.COMPLEX__INCOMING_CONDITION, oldIncomingCondition, incomingCondition));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression getOutgoingCondition() {
		if (outgoingCondition != null && outgoingCondition.eIsProxy()) {
			InternalEObject oldOutgoingCondition = (InternalEObject)outgoingCondition;
			outgoingCondition = (Expression)eResolveProxy(oldOutgoingCondition);
			if (outgoingCondition != oldOutgoingCondition) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.COMPLEX__OUTGOING_CONDITION, oldOutgoingCondition, outgoingCondition));
			}
		}
		return outgoingCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression basicGetOutgoingCondition() {
		return outgoingCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutgoingCondition(Expression newOutgoingCondition) {
		Expression oldOutgoingCondition = outgoingCondition;
		outgoingCondition = newOutgoingCondition;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.COMPLEX__OUTGOING_CONDITION, oldOutgoingCondition, outgoingCondition));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.COMPLEX__INCOMING_CONDITION:
				if (resolve) return getIncomingCondition();
				return basicGetIncomingCondition();
			case BpmnPackage.COMPLEX__OUTGOING_CONDITION:
				if (resolve) return getOutgoingCondition();
				return basicGetOutgoingCondition();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.COMPLEX__INCOMING_CONDITION:
				setIncomingCondition((Expression)newValue);
				return;
			case BpmnPackage.COMPLEX__OUTGOING_CONDITION:
				setOutgoingCondition((Expression)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.COMPLEX__INCOMING_CONDITION:
				setIncomingCondition((Expression)null);
				return;
			case BpmnPackage.COMPLEX__OUTGOING_CONDITION:
				setOutgoingCondition((Expression)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.COMPLEX__INCOMING_CONDITION:
				return incomingCondition != null;
			case BpmnPackage.COMPLEX__OUTGOING_CONDITION:
				return outgoingCondition != null;
		}
		return super.eIsSet(featureID);
	}

} //ComplexImpl
